#include "ForUSBDriver.h"

extern HANDLE CompletionPort;

void main(void)
{
	HANDLE hTh, hUSBSimulator = NULL;
	DWORD dwThreadId, dwBytesReturned;
  
	
	if ((hTh = CreateThread(NULL, 0, WorkerThread, NULL, 0, &dwThreadId)) == NULL)
	{
			cout<<("Error CreateThread: %d\n", GetLastError());
			CloseHandle(hTh);
			return;
	}
	hUSBSimulator = CreateFile(TEXT("\\\\.\\USBSimulator"), GENERIC_ALL, 0, NULL, 
							OPEN_EXISTING, 0, NULL);
	
    if(hUSBSimulator == INVALID_HANDLE_VALUE)
	{
		cout<<"fuck";
	}
	Sleep(5000);
	DeviceIoControl(hUSBSimulator, IOCTL_SIMULATE_ONE_PACKET, "Happiness\0", 11, NULL, 0, 
								&dwBytesReturned, NULL);
	Sleep(5000);
	PostQueuedCompletionStatus(CompletionPort, 0, NULL, NULL); 
	CloseHandle(hUSBSimulator);

}